package com.backend.demo1.services;

import java.util.List;

import com.backend.demo1.mapper.NonMemberMapper; // 修改为 NonMemberMapper
import com.backend.demo1.models.NonMember; // 修改为 NonMember
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class NonMemberService {

    @Autowired
    private NonMemberMapper nonMemberMapper; // 修改为 NonMemberMapper

    // 插入一个新非会员
    public void insert(NonMember nonMember) { // 修改为 NonMember
        nonMemberMapper.insert(nonMember);
    }

    // 根据ID查找非会员
    public NonMember findById(Long id) { // 修改为 NonMember 和 Long 类型
        return nonMemberMapper.findById(id);
    }

    // 查找所有非会员
    public List<NonMember> findAll() { // 修改为 NonMember
        return nonMemberMapper.findAll();
    }

    // 更新非会员信息
    public void update(NonMember nonMember) { // 修改为 NonMember
        nonMemberMapper.update(nonMember);
    }

    // 根据ID删除非会员
    public void deleteById(Long id) { // 修改为 Long 类型
        nonMemberMapper.deleteById(id);
    }

    // 检查是否已存在该会员（通过 userId）
    public boolean existsByUserId(Long userId) {
        return nonMemberMapper.existsByUserId(userId) > 0;
    }
}